package com.liang.bishi.xm;

import java.util.Scanner;

/**
 * 9.19 小米笔试
 * 第一题：
 * <p>
 * 2
 * 10 4 1
 * 2 3 5 7
 * 10 1 3
 * 6
 * <p>
 * YES
 * NO
 */
public class Problem1 {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int t = cin.nextInt();
        for (int i = 0; i < t; i++) {
            // 容量为N的箱子
            int N = cin.nextInt();
            // n个大小为a[i]的玩具
            int n = cin.nextInt();
            // 大小为1的c个填充物
            int c = cin.nextInt();
            int[] a = new int[n];
            for (int j = 0; j < n; j++) {
                a[j] = cin.nextInt();
            }
            System.out.println(getAnswer(a, N, n, c));
        }
    }

    public static String getAnswer(int[] a, int N, int n, int c) {
        boolean[] dp = new boolean[N + 1];
        // 初始化
        dp[0] = true;
        for (int i = 1; i <= N && i <= c; i++) {
            dp[i] = true;
        }
        for (int i = 0; i < n; i++) {
            for (int j = N; j >= a[i]; j--) {
                dp[j] = dp[j] || dp[j - a[i]];
            }
        }
        return dp[N] ? "YES" : "NO";
    }
}
